<template>
  <div style="margin-top: 10px">
    说明性文件：
    <template v-for="(item,index) in fileList">
      <a-button @click="downFile(item)" style="margin-right: 10px" type="dashed">
        {{item.fileName}}
      </a-button>
    </template>
  </div>
</template>

<script>
  import {httpAction, getAction} from '@/api/manage'

  export default {
    name: "FileTag",
    props: ['apiId'],
    data() {
      return {
        fileList: [],
        url: '/sjzyzhgl/sjFileInfo/commonFileInfo'
      }
    },
    watch: {
      apiId: {
        handler() {
          this.getFile()
        },
        immediate: true
      }
    },
    methods: {
      downFile(data) {
        this.$message.success('正在下载，请稍等！')
        let url = `${window._CONFIG['domianURL']}/sys/common/static/${data.url}`
        window.open(url, '_blank')
      },
      getFile() {
        getAction(this.url, {id: this.apiId}).then((res) => {
          if (res.success && res.result) {
            this.fileList = res.result.affixList
          } else {
            console.log(res)
          }
        })
      },
    }
  }
</script>

<style scoped>

</style>